<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改sybx')" />
            <th:block th:include="include :: datetimepicker-css" />
</head>
<style>
    .jltable{
        margin: auto;
    }
    .jltable th,td{
        min-height: 40px;
        min-width: 50px;
        border: 1px solid #eee;
        padding: 10px;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-sybx-edit" th:object="${lwpqSybx}">
        <h4 class="form-header h4">商业保险信息</h4>
        <table class="jltable">
            <tbody>
        <input name="id" th:field="*{id}" type="hidden">
            <tr>
                <td><label class="control-label">投保开始时间：</label></td>
                <td>
                    <div class="input-group date">
                        <input name="tbkssj" th:value="${#dates.format(lwpqSybx.tbkssj, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </td>
                <td><label class="control-label">投保结束时间：</label></td>
                <td>
                    <div class="input-group date">
                        <input name="tbjssj" th:value="${#dates.format(lwpqSybx.tbjssj, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </td>
            </tr>
                <tr>
                    <td><label class="control-label">商保机构：</label></td>
                    <td> <input name="sbjg" th:field="*{sbjg}" class="form-control" type="text"></td>
                    <td><label class="control-label">投保金额：</label></td>
                    <td> <input name="tbje" th:field="*{tbje}" class="form-control" type="text"></td>
                </tr>

                <tr>
                    <td><label class="control-label">负责人：</label></td>
                    <td> <input name="fzr" th:field="*{fzr}" class="form-control" type="text"></td>
                    <td><label class="control-label">实保金额：</label></td>
                    <td> <input name="sbje" th:field="*{sbje}" class="form-control" type="text"></td>
                </tr>

                <tr>
                    <td><label class="control-label">联系电话：</label></td>
                    <td> <input name="lxdh" th:field="*{lxdh}" class="form-control" type="text"></td>
                    <td><label class="control-label">办理结果：</label></td>
                    <td> <input name="bljg" th:field="*{bljg}" class="form-control" type="text"></td>
                </tr>
            <tr>
                <td><label class="control-label">投保内容：</label></td>
                <td colspan="3"><textarea name="tbnr" class="form-control">[[*{tbnr}]]</textarea></td>
            </tr>
            </tbody>
        </table>
        <h4 class="form-header h4" style="margin-top: 20px">参保人员信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "lwpq/sybx";
    $("#form-sybx-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-sybx-edit').serialize());
        }
    }

            $("input[name='tbkssj']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });

            $("input[name='tbjssj']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });

        $(function() {
            var options = {
                data: [[${lwpqSybx.lwpqCbryList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                        var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                        return columnIndex + $.table.serialNumber(index);
                    }
                },
                    {
                        field: 'name',
                        align: 'center',
                        title: '姓名',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqCbryList[%s].name' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'sfzh',
                        align: 'center',
                        title: '身份证',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqCbryList[%s].sfzh' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'tbje',
                        align: 'center',
                        title: '投保金额',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqCbryList[%s].tbje' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'tbjg',
                        align: 'center',
                        title: '投保结果',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqCbryList[%s].tbjg' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'tbnr',
                        align: 'center',
                        title: '投保内容',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqCbryList[%s].tbnr' value='%s'>", index, value);
                            return html;
                        }

            }]
        };
        $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();

            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                                name: "",

                                sfzh: "",

                                tbje: "",

                                tbjg: "",

                                tbnr: "",

                                createBy: "",

                                updateBy: "",

                                createTime: "",

                                updateTime: ""

                }
            });
        }
</script>
</body>
</html>